package com.atguigu.gmall.wms.mapper;

import com.atguigu.gmall.wms.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * 商品库存
 * 
 * @author 嘉岭月天
 * @email 嘉岭月天@cnnc.com
 * @date 2021-11-29 19:48:03
 */
@Mapper
public interface WareSkuMapper extends BaseMapper<WareSkuEntity> {
    // 查询库存中skuId的商品是否足够
    List<WareSkuEntity> check(@Param("skuId") Long skuId, @Param("count") Integer count);

    // 根据订单信息锁定库存
    int lock(@Param("id")Long id, @Param("count")Integer count);

    // 多个商品锁库存 失败一个后需要将其他锁库存成功的商品解锁
    int unlock(@Param("id")Long id, @Param("count")Integer count);
}
